package com.sasis.model;

public class BasePermission extends BaseEntity implements Permission {

	private static final long serialVersionUID = 1L;

	private Principal principal;

	private Subject subject;
	
	private boolean allow = true;
	
	public BasePermission() {
		
	}
	
	public BasePermission(Principal principal, Subject subject, boolean allow) {
		this.principal = principal;
		this.subject = subject;
		this.allow = allow;
	}
	
	public boolean isAllow() {
		return allow;
	}

	public void setAllow(boolean allow) {
		this.allow = allow;
	}

	public Principal getPrincipal() {
		return principal;
	}

	public void setPrincipal(Principal principal) {
		this.principal = principal;
	}

	public Subject getSubject() {
		return subject;
	}

	public void setSubject(Subject subject) {
		this.subject = subject;
	}
	
	/*public String getTable() {
		String prefix = "USER_";
		if (principal.isRole()) {
			prefix = "ROLE_";
		}
		String suffix = "PERMREG";
		if (subject.isFunction()) {
			suffix = "RIGHT_LIST";
		}
		return prefix + suffix;
	}
	
	public String getPrincipalField() {
		if (principal.isRole()) {
			return "USER_REF_ID";
		}
		return "ROL_REF_ID";
	}
	
	public String getSubjectField() {
		if (subject.isFunction()) {
			return "FUNC_ID";
		}
		return "PERM_ID";
	}*/
}
